import axios from 'axios'
import { Storage } from '../../storage'

const login = (teaNumber, password) =>
    axios.post('/api/tea/login', { teaNumber, password })
    .then(res => res.data)

const delStuById = (stuId) => axios.delete(`/api/stu/info/class/${stuId}`).then(res => res.data)

//axios delete参数，第二个就是config，没有data，那没办法，我们只能使用config.data来配置参数
const delStuBatch = (stuIds) => axios.delete('/api/stu/info/batch', {
    data: {
        stuIds
    }
}).then(res => res.data)

const getOneUserByName = (stuName) => axios.get('/api/stu/info', {
    params: {
        stuName
    }
}).then(res => res.data)


const registerTea = (form) => axios.post("/api/tea/register", form).then(res => res.data)

const getMyMsgRecord = () => axios.get(`/api/message-record/get/false`, {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const replyStuRecord = (form) => axios.put('/api/message-record/reply', form).then(res => res.data)

export {
    login,
    delStuById,
    delStuBatch,
    getOneUserByName,
    registerTea,
    getMyMsgRecord,
    replyStuRecord
}